package com.zlm.user.emp.controller;

import com.zlm.common.base.BaseController;
import com.zlm.common.constants.CodeConstants;
import com.zlm.common.dto.JsonResultDto;
import com.zlm.common.entity.SysBannerDO;
import com.zlm.user.emp.service.SysBannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: duyufu
 * @Date: 2019/4/23 15:31
 */
@RestController
@RequestMapping("/banner")
public class SysBannerController extends BaseController {

    @Autowired
    public SysBannerService sysBannerService;

    /**
     * 按类别获取轮播图列表
     *
     * @param type
     * @return
     */
    @GetMapping("/getSysBannerByType")
    public JsonResultDto getSysBannerByType(Integer type) {
        try {
            List<SysBannerDO> bannerList = sysBannerService.getEntityByType(type);
            return success(bannerList);
        } catch (Exception e) {
            e.printStackTrace();
            return fail(CodeConstants.CODE_BUSY);
        }
    }
}
